﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class administrator_chi_tiet : System.Web.UI.Page
{

    dulieuDataContext _db = new dulieuDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadDetail();
        }
    }
    protected void LoadDetail()
    {
        int madonhang = Convert.ToInt16(Session["madonhang"]);
        rpt.DataSource = (_db.View1_chi_tiet_don_hangs.Where(o => o.Order_ID == madonhang));
        rpt.DataBind();
        rpt1.DataSource = (_db.Orders.Where(o => o.Order_ID == madonhang));
        rpt1.DataBind();
    }

    protected void Unnamed2Click(object sender, EventArgs e)
    {
        var dathang = (_db.Orders.Where(o => o.Order_ID == Convert.ToInt16(Session["madonhang"])));
        var chitietdathang = (_db.OrderDetails.Where(o => o.Order_ID == Convert.ToInt16(Session["madonhang"]))).FirstOrDefault();
        _db.Orders.DeleteAllOnSubmit(dathang);
        if (chitietdathang != null) _db.OrderDetails.DeleteOnSubmit(chitietdathang);
        _db.SubmitChanges();
        Response.Redirect("cart.aspx");
    }

    protected void Unnamed1Click(object sender, EventArgs e)
    {

    }
}
